﻿using System;

namespace DimensionsHelper.Common.Metadata.Script;

internal static class ThrowHelper
{
    internal static Exception InvalidToken(int start, string kind)
    {
        return new Exception($"无效的Token，位置：{start}，需要类型：{kind}。");
    }

    internal static Exception IntegerIsInvalid()
    {
        return new Exception("无效整数。");
    }

    internal static Exception DoubleIsInvalid()
    {
        return new Exception("无效小数。");
    }

    internal static Exception InvalidExpression(int start, string expression)
    {
        return new Exception($"表达式'{expression}'无效，位置：{start}。");
    }

    internal static Exception StringCannotConvertTo(string expression, string targetTypeName)
    {
        return new Exception($"无法将字符串'{expression}'转换成'{targetTypeName}'类型。");
    }

    internal static Exception StringCannotConvertToNumber(string expression)
    {
        return new Exception($"无法将字符串'{expression}'转换成数字。");
    }

    internal static Exception InvalidCategoricalElement(string expression)
    {
        return new Exception($"无效的Categorical元素: '{expression}'。");
    }

    internal static Exception UnsupportedFunction(int start, string name)
    {
        return new Exception($"不支持的函数：{name}，位置：{start}。");
    }

    internal static Exception CategoricalValueIsNotDefined(int start, string name)
    {
        return new Exception($"分类名'{name}'未定义，位置：{start}。");
    }

    internal static Exception TypeConvertFailed(string source, string targetType)
    {
        return new Exception($"无法将'{source}'转换成{targetType}类型。");
    }

    internal static Exception UnsupportedOperatorOfTypes(string op, string leftType, string rightType)
    {
        return new Exception($"{op} 操作符在类型{leftType}和类型{rightType}之间不支持。");
    }

    internal static Exception ZeroCannotBeDivisor()
    {
        return new Exception("0 不能做除数。");
    }
}